<%@ page import="com.dzxcqmxm.Dao.AlbumDao" %>
<%@ page import="com.dzxcqmxm.Dao.impl.AlbumDaoImpl" %>
<%@ page import="com.dzxcqmxm.JB.Album" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.dzxcqmxm.Dao.PhotoDao" %>
<%@ page import="com.dzxcqmxm.Dao.impl.PhotoDaoImpl" %>
<%@ page import="com.dzxcqmxm.JB.Photo" %><%--
 存放有个人中心那个页面
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>天使用户首页</title>
    <style>
        .left{
            background-color: #b0f9dc;
            width: 15%;
            height: 600px;
            float: left;
            margin: 0 auto;

        }

        .right{
            background-color: #CFFCEA;
            width: 85%;
            height: 600px;
            float: left;
        }
        .logo{
            margin: 0 auto;
            width: 200px;
            height: 130px;
        }
        ul{
            margin-top: 50px;
            list-style: none;
            width: 100%;
            height: 90px;
            line-height: 30px;
            background-color: #80F6DE;
            padding-left: 20px;
        }
        li{
            margin-left: 50px;
        }

        .top{
            width: 100%;
            height:100px;
        }
        .bottom{
            width:100%;
            height: 500px;
        }
        .in{
            background-color: #d4f1ef;
        }
        .bt{
            background-color: rgba(246, 244, 244, 0.02);
        }
        /*.album{
            float:left;
            width: 102px;
            height: 102px;
            !*设置文本居中就对了！！*!
            text-align:center;
            border: 3px red solid;
        }*/
        .album{
            float: left;
            /*width: 102px;*/
            /*height: 102px;*/
            text-align: center;
        }
        .xc{
            width: 100px;
            height: 100px;
        }

    </style>
</head>
<body>
<div>
    <div class="left">
        <div>
            <p>欢迎你登录</p>
            <img class="logo" src="../img/logo.jpg">
        </div>
        <ul>
            <a><li>公开照片</li></a>
            <a href="YongHuShouYe2.jsp"><li>个人空间</li></a>
            <a href="/dzxc/login/login.jsp"><li>退出登录</li></a>
        </ul>

    </div>
    <div class="right">
        <div class="top">
            <form action="/dzxc/albumFindByNameAndAlbumBaoMiServlet" method="POST">
                <p><input class="in" name="AlbumName" type="text"/> <input class="bt" type="submit" value="查找所有公开相册"/></p>
            </form>
            <form action="/dzxc/photoFindByNameAndPhotoBaoMiServlet" method="POST">
                <p><input name="PhotoName" class="in" type="text"/> <input class="bt" type="submit" value="查找所有公开照片"/></p>
            </form>

        </div>
        <div class="bottom">
            <h2>这里是展示公开相册/照片的页面</h2>
            <%
                PhotoDao photoDao = new PhotoDaoImpl();
                AlbumDao albumDao = new AlbumDaoImpl();
                ArrayList<Photo> photoArrayList = new ArrayList<Photo>();
                ArrayList<Album> albumArrayList = new ArrayList<Album>();
                /**
                 * 获取servlet页面中的session参数,而servlet是albumFindByNameAndAlbumBaoMiServlet
                 */
                photoArrayList = (ArrayList<Photo>) session.getAttribute("photoArrayList");

                albumArrayList = (ArrayList<Album>) session.getAttribute("albumArrayList");

                System.out.println("测试一下在用户首页1的photoArrayList"+photoArrayList);
                System.out.println("测试一下在用户首页1的albumArrayList"+albumArrayList);
                if(albumArrayList!=null&&albumArrayList.size()>0){
                    for(Album album :albumArrayList){
            %>
            <div class="album">
                <img class="xc" src="../img/album.png">
                <p><%
                    /**
                     * 因为这是公开首页所以不用限制用户，要用其他方法
                     * 直接查找照片，通过照片名即可
                     *
                     */
                    out.println("<tr><td><a href='/dzxc/photoFindbyAlbumUrlServlet?AlbumUrl="+album.getAlbumUrl()+ "'>" +
                            album.getAlbumName() +
                            "</a></td></tr><br><br><br><br><br><br>");
                %></p>

            </div>
            <%
                    }
                }
            %>

            <%
                /**
                 * 上边是相册，这里是照片
                 */
            if(photoArrayList!=null&&photoArrayList.size()>0){
            for(Photo photo :photoArrayList){
                request.setAttribute("PhotoUrl",photo.getPhotoUrl());
            %>
            <div class="album">
                <img class="xc" src=/${PhotoUrl}>
                <br>
                <p><%
                    out.println("<tr><td>" +
                            photo.getPhotoName() +
                            "</td></tr><br><br>");
                %></p>



            </div>
            <%
                }
            }
            %>


        </div>
    </div>
</div>
</body>
</html>
